package com.xm.data.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xm.data.entiry.HistoryData;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface HistoryMapper extends BaseMapper<HistoryData> {
    @Insert("<script>" +
            "INSERT INTO ${tableName} " +
            "(client_id, timestamp, cpu_usage, memory_usage, disk_usage, " +
            "network_upload, network_download, disk_write, disk_read) " +
            "VALUES " +
            "<foreach collection='list' item='item' separator=','>" +
            "(#{item.clientId}, #{item.timestamp}, #{item.cpuUsage}, " +
            "#{item.memoryUsage}, #{item.diskUsage}, #{item.networkUpload}, " +
            "#{item.networkDownload}, #{item.diskWrite}, #{item.diskRead})" +
            "</foreach>" +
            "</script>")
    void batchInsert(@Param("tableName") String tableName,
                     @Param("list") List<HistoryData> list);
}

